#!/usr/bin/env python

import subprocess
import os
from config import KIND, APP_NAME, PRODUCTION_SERVER, DATA_DIR

print("Downloading %s entities from %s on %s ..." % (KIND, APP_NAME, PRODUCTION_SERVER))

# appcfg.py download_data --application=bookburrito-db --kind=Library --url=http://bookburrito-db.appspot.com/_ah/remote_api --filename=data_Library
if True:
    cwd = os.getcwd()
    try:
        os.chdir(DATA_DIR)
        subprocess.call([
            "appcfg.py",
            "download_data",
            "--application=" + APP_NAME,
            "--kind=" + KIND,
            "--url=http://bookburrito-db.appspot.com/_ah/remote_api",
            "--filename=data_" + KIND,
            ])
    finally:
        os.chdir(cwd)
    
